using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BulletController_Enemy : MonoBehaviour
{
    public Rigidbody2D rbody;
    public Animator animator;
    void Awake()
    {
        rbody = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
    }
    public void Move(Vector2 direction, float speed)
    {
        rbody.AddForce(direction * speed);
    }

    public void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerController pc = collision.collider.GetComponent<PlayerController>();
        if (pc != null)
        {
            // pc.ChangeHealth(-10);
            rbody.simulated = false;
            animator.SetTrigger("isExplode");
        }
        else
        {
            rbody.simulated = false;
            animator.SetTrigger("isExplode");
        }
    }

    public void OnDestroy()
    {
        Destroy(gameObject);
    }
}
